package org.wlldTest.lesson4;

import org.dromara.easyai.entity.ThreeChannelMatrix;
import org.dromara.easyai.matrixTools.Matrix;
import org.dromara.easyai.matrixTools.MatrixOperation;
import org.dromara.easyai.tools.ImageTools;
import org.dromara.easyai.tools.Picture;

public class Test {
    public static void main(String[] args) throws Exception {
        MatrixOperation operation = new MatrixOperation();
        ThreeChannelMatrix three = Picture.getThreeMatrix("D:\\lesson/t.png",false);
        int x = three.getX();//当前三通道的行数 也就是 等同于图像的高度
        int y = three.getY();//列数，等同于图像的宽度
        ThreeChannelMatrix t = three.cutChannel(0, 0, x / 2, y / 2);
        Matrix matrixR = t.getMatrixR();//r通道
        Matrix matrixG = t.getMatrixG();//g通道
        Matrix matrixB = t.getMatrixB();
        Matrix matrix = new Matrix(t.getX(), t.getY());
        for (int i = 0; i < t.getX(); i++) {
            for (int j = 0; j < t.getY(); j++) {
                matrix.setNub(i, j, 50 / 255f);
            }
        }
        matrixR = operation.add(matrixR, matrix);
        matrixG = operation.add(matrixG, matrix);
        matrixB = operation.add(matrixB, matrix);
        Matrix matrix1R = three.getMatrixR();
        Matrix matrix1G = three.getMatrixG();
        Matrix matrix1B = three.getMatrixB();
        for (int i = 0; i < x / 2; i++) {
            for (int j = 0; j < y / 2; j++) {
                matrix1R.setNub(i, j, matrixR.getNumber(i, j));
                matrix1G.setNub(i, j, matrixG.getNumber(i, j));
                matrix1B.setNub(i, j, matrixB.getNumber(i, j));
            }
        }
        ImageTools imageTools = new ImageTools();
        imageTools.writeImage(three, "D:\\lesson/f.png");
    }
}
